#include "ScrTitle.h"
#include "Renderer.h"
#include "ScreenManager.h"
#include "ScrGame.h"
#include "Game.h"
#include "Constant.h"
#include <sstream>

ScrTitle::ScrTitle(void) : GameScreen()
{
}
ScrTitle::~ScrTitle(void)
{
}

string ScrTitle::GetInternalName()
{
	return string("TitleScreen");
}
void ScrTitle::Render()
{
	vector2 screen = m_pRenderer->GetScreenSize();
	m_pRenderer->SetFillMode(FM_Solid);
	m_pRenderer->SetColor(color::Yellow);
	m_pRenderer->DrawRect2D(vector2(400,300), vector2(400,300), 90.0f, vector2(0,0));

	//Render debug status textn
	stringstream status;
	status << "No GUI-system Implemented yet" << endl;
	status << "Press N to Generate a new world" << endl << endl;
	int xText = 2;
	int yText = m_pRenderer->PrintStr2D(vector2(xText,16), status.str(), color::White);
	status.flush();
	status << "The right control key allows system commands in debug mode: " << endl;
	status << "CTRL + Q Force quits the game" << endl;
	status << "CTRL + F Dumps the FPS to the console" << endl;
	status << "CTRL + S Dumps the screen stack to the console" << endl;
	yText = m_pRenderer->PrintStr2D(vector2(xText, yText), status.str(), color::Green);
}
void ScrTitle::Update()
{
	
}
void ScrTitle::StartMain()
{
	GameScreenPtr gameScr(new ScrGame());
	m_pScreenManager->AddScreenAfter(gameScr, this);
	m_pScreenManager->RemoveScreen(this);
}
void ScrTitle::OnKeyPress(uint key)
{
	if(key == SDLK_n)
	{
		StartMain();
	}
}
void ScrTitle::OnKeyRelease(uint key)
{

}
bool ScrTitle::ScreenInit(IGame *pGame)
{
	if(!GameScreen::ScreenInit(pGame))
		return false;
	return true;
}